﻿using com.ytocargo.Core.FlightInfos;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yto.AutoMapper.Attributes;
using Yto.Entities;
using AutoMapper.Configuration.Annotations;
using com.ytocargo.Core.FlightInfoSubs;

namespace com.ytocargo.Core.FlightInfo4Monitors
{
    [Table("YTO_FLIGHTINFO4MONITOR")]
    public class FlightInfo4Monitor : Entity
    {
        public const int COMMONLENGTH = 15;

        [Ignore]
        public override int Id { get => base.Id; set => base.Id = value; }

        [Required]
        public int FlightId { get; set; }

        //IATA代码（两字码）
        [Required]
        [StringLength(2)]
        public string CompanyCode2 { get; set; } = "YG";

        //ICAO代码（三字码）
        [Required]
        [StringLength(3)]
        public string CompanyCode3 { get; set; } = "HYT";

        //航班号，需求是5位，默认3位（可以超过3位），不足3位前缀用0补全
        [Required]
        [StringLength(10)]
        public string FltId { get; set; }

        //航班号后缀
        [StringLength(2)]
        public string FltIdFix { get; set; }

        //航段序号
        [Required]
        public decimal FltSeq { get; set; }

        //航班日期
        public DateTime FltDate { get; set; }

        //分公司号,这个值没有，必填
        [Required]
        [StringLength(2)]
        public string CoSeq { get; set; } = "YG";

        //航班性质
        [StringLength(3)]
        public string FltTask { get; set; }

        //服务类型
        [StringLength(1)]
        public string ServiceType { get; set; }

        //10（商委）航班类型
        [Required]
        [StringLength(1)]
        public string FltType { get; set; }

        //（运行）航班类型
        [Required]
        [StringLength(1)]
        public string FltOpType { get; set; }

        //航班状态
        [Required]
        [StringLength(3)]
        public string FltStatus { get; set; }

        //AF衔接航班号
        [StringLength(5)]
        public string ConFltId { get; set; }

        //AF衔接航班号后缀
        [StringLength(2)]
        public string ConFltIdFix { get; set; }

        //15AF衔接公司代码（两字码）
        [StringLength(2)]
        public string ConCompanyCode2 { get; set; }

        //AF衔接航班日期
        public DateTime? ConFltDate { get; set; }

        //航班环ID
        [StringLength(7)]
        public string FltLoopId { get; set; }

        //计划起飞时间
        [Required]
        public DateTime Std { get; set; }

        //计划落地时间
        [Required]
        public DateTime Sta { get; set; }

        //20.计划起飞机场（三字码）
        [Required]
        [StringLength(3)]
        public string SchDepApt { get; set; }

        //计划落地机场（三字码）
        [Required]
        [StringLength(3)]
        public string SchArrApt { get; set; }

        //预计起飞时间
        public DateTime? Etd { get; set; }

        //预计落地时间
        public DateTime? Eta { get; set; }

        //实际起飞机场（三字码）
        [Required]
        [StringLength(3)]
        public string DepApt { get; set; }

        //25实际落地机场（三字码）
        [Required]
        [StringLength(3)]
        public string ArrApt { get; set; }

        //最新起飞时间
        public DateTime? LatestOffTime { get; set; }

        //最新落地时间
        public DateTime? LatestOnTime { get; set; }

        //最新起飞状态
        [Required]
        [StringLength(3)]
        public string LatestOffStatus { get; set; } = "000";

        //最新落地状态
        [Required]
        [StringLength(3)]
        public string LatestOnStatus { get; set; } = "000";

        //30关门时间
        public DateTime? DoorCloseTime { get; set; }

        //撤轮档时间
        public DateTime? OffBlockTime { get; set; }

        //推出时间
        public DateTime? OutTime { get; set; }

        //滑出时间
        public DateTime? TaxioutTime { get; set; }

        //实际起飞时间
        public DateTime? OffTime { get; set; }

        //35实际落地时间
        public DateTime? OnTime { get; set; }

        //滑入时间
        public DateTime? TaxiinTime { get; set; }

        //推入时间
        public DateTime? InTime { get; set; }

        //挡轮档时间
        public DateTime? OnBlockTime { get; set; }

        //开门时间
        public DateTime? DoorsOpnTime { get; set; }

        //40计划起飞时间来源
        [StringLength(COMMONLENGTH)]
        public string StdSrc { get; set; }

        //计划落地时间来源
        [StringLength(COMMONLENGTH)]
        public string StaSrc { get; set; }

        //预计起飞时间来源
        [StringLength(COMMONLENGTH)]
        public string EtdSrc { get; set; }

        //预计落地时间来源
        [StringLength(COMMONLENGTH)]
        public string EtaSrc { get; set; }

        //最新起飞时间来源
        [StringLength(COMMONLENGTH)]
        public string LatestOffTimeSrc { get; set; }

        //45最新落地时间来源
        [StringLength(COMMONLENGTH)]
        public string LatestOnTimeSrc { get; set; }

        //最新起飞状态来源
        [StringLength(COMMONLENGTH)]
        public string LatestOffStatusSrc { get; set; }

        //最新落地状态来源
        [StringLength(COMMONLENGTH)]
        public string LatestOnStatusSrc { get; set; }

        //关门时间来源
        [StringLength(COMMONLENGTH)]
        public string DoorCloseTimeSrc { get; set; }

        //撤轮档时间来源
        [StringLength(COMMONLENGTH)]
        public string OffBlockTimeSrc { get; set; }

        //50推出时间来源
        [StringLength(COMMONLENGTH)]
        public string OutTimeSrc { get; set; }

        //滑出时间来源
        [StringLength(COMMONLENGTH)]
        public string TaxioutTimeSrc { get; set; }

        //实际起飞时间来源
        [StringLength(COMMONLENGTH)]
        public string OffTimeSrc { get; set; }

        //实际落地时间来源
        [StringLength(COMMONLENGTH)]
        public string OnTimeSrc { get; set; }

        //滑入时间来源
        [StringLength(COMMONLENGTH)]
        public string TaxiinTimeSrc { get; set; }

        //55推入时间来源
        [StringLength(COMMONLENGTH)]
        public string InTimeSrc { get; set; }

        //挡轮档时间来源
        [StringLength(COMMONLENGTH)]
        public string OnBlockTimeSrc { get; set; }

        //开门时间来源
        [StringLength(COMMONLENGTH)]
        public string DoorsOpnTimeSrc { get; set; }

        //最新更新来源
        [Required]
        [StringLength(COMMONLENGTH)]
        public string LatestUpdateSrc { get; set; } = "FOC";

        //处理时间
        [Required]
        public DateTime DealTime { get; set; }

        //60备降id,原始航段主键Id
        [Required]
        [StringLength(40)]
        public string FltIdAltn { get; set; } = "000";

        [Required]
        //实际航段序号
        public int FltSeqReal { get; set; }

        //航段主键ID
        [Required]
        [StringLength(40)]
        public string FltIdPk { get; set; } = "000";

        //开始上客时间
        public DateTime? StartCheckTime { get; set; }

        //计划起飞时间Local时
        [Required]
        public DateTime StdLocal { get; set; }

        //65计划落地时间Local时
        [Required]
        public DateTime StaLocal { get; set; }

        //预计起飞时间Local时
        public DateTime? EtdLocal { get; set; }

        //预计落地时间Local时
        public DateTime? EtaLocal { get; set; }

        //关门时间Local时
        public DateTime? DoorCloseTimeLocal { get; set; }

        //撤轮档时间Local时
        public DateTime? OffBlockTimeLocal { get; set; }

        //70推出时间Local时
        public DateTime? OutTimeLocal { get; set; }

        //滑出时间Local时
        public DateTime? TaxioutTimeLocal { get; set; }

        //实际起飞时间Local时
        public DateTime? OffTimeLocal { get; set; }

        //实际落地时间Local时
        public DateTime? OnTimeLocal { get; set; }

        //滑入时间Local时
        public DateTime? TaxiinTimeLocal { get; set; }

        //75推入时间Local时
        public DateTime? InTimeLocal { get; set; }

        //挡轮挡时间Local时
        public DateTime? OnBlockTimeLocal { get; set; }

        //开门时间Local时
        public DateTime? DoorsOpnTimeLocal { get; set; }

        //mm系统航段唯一标识
        public long SoflSeqNr { get; set; }

        //航班日期北京时
        [NotMapped]
        public DateTime FltDatePek { get { return FltDate; } }

        //80.ODS更改时间
        [Required]
        public DateTime ChangeTime { get; set; }

        //关货舱门时间UTC时
        [NotMapped]
        public DateTime CargoDoorCloseTime { get { return CargoDoorCloseTimeLocal.ToUniversalTime(); } }

        //关货舱门时间lcoal时
        [Required]
        public DateTime CargoDoorCloseTimeLocal { get; set; }

        //关客舱门时间UTC时,必填，取关货仓时间
        [NotMapped]
        public DateTime CabinDoorCloseTime { get { return CabinDoorCloseTimeLocal.ToUniversalTime(); } }

        //关客舱门时间lcoal时
        [NotMapped]
        public DateTime CabinDoorCloseTimeLocal { get { return CargoDoorCloseTimeLocal; } }

        //全局航班主键
        [StringLength(11)]
        public string GlobalPk { get; set; }

        [NotMapped]
        public FlightInfoSub FlightInfoSub { get; set; }
    }
}
